Skip to content

Resolve export * as ns re-exports under modern parsers#3250

Merged
ljharb merged 1 commit into
import-js:mainfrom
rasmi:export-star-as-fix
May 20, 2026
Merged

Resolve export * as ns re-exports under modern parsers#3250
ljharb merged 1 commit into
import-js:mainfrom
rasmi:export-star-as-fix

Conversation

@rasmi
Copy link
Copy Markdown
Contributor

@rasmi rasmi commented May 18, 2026

Fixes two pre-existing ExportAllDeclaration bugs that affect modern parsers (espree ES2020+, @babel/eslint-parser) but not babel-eslint. Extracted from #3230 (eslint v10 support) to make that PR cleaner.

Root cause

babel-eslint represents export * as ns from './mod' as ExportNamedDeclaration + ExportNamespaceSpecifier (a working code path), so the bug was latent. Modern parsers emit ExportAllDeclaration with exported, which hit two broken spots:

  • specifier.js: passed a string (specifier.source.value) to namespace.add(), which expects an AST node — so the namespace getter was never set up and ns didn't resolve. Fixed by defining the lazy getter directly, matching the existing ExportNamespaceSpecifier case.
  • visitor.js: export * as ns was unconditionally added to the star-export dependencies set, incorrectly flattening the target module's exports into the current one. Fixed by only adding to dependencies for plain export * (no as).

Tests

The included regression test covers the false negative: the namespace rule now correctly flags invalid deep references through export * as re-exports that were previously silently missed (fails on main, passes with the fix).

The false-positive symptoms #1834, #1883, #1845, #2002, #2289 ("errors after upgrading Babel") are resolved by the same change, but only reproduce with @babel/eslint-parser, which is introduced in #3230.

Fixes #2002, #1883, #1834, #1845, #2289.

@rasmi rasmi force-pushed the export-star-as-fix branch from de05c15 to 8860796 Compare May 18, 2026 03:11
@rasmi rasmi force-pushed the export-star-as-fix branch from 8860796 to 15dcddd Compare May 18, 2026 03:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.52%. Comparing base (dba25f2) to head (8e5c66b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3250      +/-   ##
==========================================
- Coverage   95.68%   95.52%   -0.16%     
==========================================
  Files          83       83              
  Lines        3705     3709       +4     
  Branches     1342     1342              
==========================================
- Hits         3545     3543       -2     
- Misses        160      166       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/exportMap/specifier.js Outdated
@ljharb ljharb force-pushed the export-star-as-fix branch 2 times, most recently from 8e5c66b to d4de15e Compare May 20, 2026 14:23
@ljharb ljharb merged commit d4de15e into import-js:main May 20, 2026
403 of 404 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[export] incorrect report on export * as

3 participants